package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeConAnnouncement;
import com.htgd.gardenexpo.dao.GeConAnnouncementDao;
import com.htgd.gardenexpo.entity.PageQuery;
import com.htgd.gardenexpo.service.GeConAnnouncementService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公告表(GeConAnnouncement)表服务实现类
 *
 * @author makejava
 * @since 2021-06-09 15:43:49
 */
@Service("geConAnnouncementService")
public class GeConAnnouncementServiceImpl implements GeConAnnouncementService {
    @Resource
    private GeConAnnouncementDao geConAnnouncementDao;

    /**
     * 通过ID查询单条数据
     *
     * @param announcementId 主键
     * @return 实例对象
     */
    @Override
    public GeConAnnouncement queryById(Integer announcementId) {
        return this.geConAnnouncementDao.queryById(announcementId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeConAnnouncement> queryAllByLimit(int offset, int limit) {
        return this.geConAnnouncementDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<GeConAnnouncement> getAllHomeAnnouncement() {
        return this.geConAnnouncementDao.getAllHomeAnnouncement();
    }

    @Override
    public List<GeConAnnouncement> getAllAnnouncementByValue(PageQuery pageQuery) {
        return this.geConAnnouncementDao.getAllAnnouncementByValue(pageQuery);
    }

    @Override
    public List<GeConAnnouncement> getAllAnnouncementByValueNoContent(PageQuery pageQuery) {
        return this.geConAnnouncementDao.getAllAnnouncementByValueNoContent(pageQuery);
    }

    /**
     * 新增数据
     *
     * @param geConAnnouncement 实例对象
     * @return 实例对象
     */
    @Override
    public GeConAnnouncement insert(GeConAnnouncement geConAnnouncement) {
        this.geConAnnouncementDao.insert(geConAnnouncement);
        return geConAnnouncement;
    }

    /**
     * 修改数据
     *
     * @param geConAnnouncement 实例对象
     * @return 实例对象
     */
    @Override
    public GeConAnnouncement update(GeConAnnouncement geConAnnouncement) {
        this.geConAnnouncementDao.update(geConAnnouncement);
        return this.queryById(geConAnnouncement.getAnnouncementId());
    }

    /**
     * 通过主键删除数据
     *
     * @param announcementId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer announcementId) {
        return this.geConAnnouncementDao.deleteById(announcementId) > 0;
    }
}
